FROM openjdk:8-jdk-alpine

RUN echo 'Asia/Shanghai' > /etc/timezone && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

WORKDIR /opt/app

ARG KETTLE_FILE="pdi-ce-7.1.0.0-12"
ARG KETTLE_DOWNLOAD="https://nchc.dl.sourceforge.net/project/pentaho/Data%20Integration/7.1/pdi-ce-7.1.0.0-12.zip"
ARG UNZIP_KETTLE_DOWNLOAD="data-integration"
ARG NEW_NAME="kettle71"

RUN apk --update add ca-certificates openssl wget tzdata \
    && update-ca-certificates \
    && wget ${KETTLE_DOWNLOAD} -O ${KETTLE_FILE}.zip \
    && unzip ${KETTLE_FILE}.zip \
    && rm -rf ${KETTLE_FILE}.zip \
    && mkdir ${NEW_NAME} \
    && mv ${UNZIP_KETTLE_DOWNLOAD} ${NEW_NAME}

RUN mkdir /root/.kettle
COPY files/repositories.xml /root/.kettle
COPY files/entrypoint.sh /entrypoint.sh
COPY files/crontab crontab
COPY files/busybox /usr/bin/busybox
COPY files/cacerts /usr/lib/jvm/default-jvm/jre/lib/security/

RUN chmod a+x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]